package com.ihome.android.util;

import android.content.pm.IPackageStatsObserver;
import android.content.pm.PackageStats;
import android.os.RemoteException;
import android.text.format.Formatter;
import android.util.Log;

import com.ihome.android.market2.info.AppInfo;

/**
 * aidl文件形成的Bindler机制服务类
 */
public class PkgSizeObserver extends IPackageStatsObserver.Stub {
	private static final String	TAG	= PkgSizeObserver.class.getSimpleName();
	private AppInfo		appinfo;

	public PkgSizeObserver(AppInfo appinfo) {
		this.appinfo = appinfo;
	}

	/***
	 * 回调函数，
	 * 
	 * @param pStatus
	 *            ,返回数据封装在PackageStats对象中
	 * @param succeeded
	 *            代表回调成功
	 */
	@Override
	public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {

		appinfo.cachesize = pStats.cacheSize; //缓存大小
		appinfo.datasize = pStats.dataSize; //数据大小 
		appinfo.codesize = pStats.codeSize; //应用程序大小
		appinfo.totalsize = appinfo.cachesize + appinfo.datasize + appinfo.codesize;
		//appinfo.totalsize = Tools.divide(total, 1l, 2);
		//Log.i(TAG, "cachesize--->" + appinfo.cachesize + " datasize---->" + appinfo.datasize + " codeSize---->" + appinfo.codesize);
	}
}